package org.groupg.practice;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.select.Select;

public class BasicParser {
    public static void main(String[] args) {
        String sql = "SELECT id, name FROM users WHERE age > 25";

        try {
            // 核心解析方法：将SQL转为Statement对象
            Statement statement = CCJSqlParserUtil.parse(sql);

            // 判断语句类型
            if (statement instanceof Select select) {
                System.out.println("解析到SELECT语句: " + select);
            }
        } catch (JSQLParserException e) {
            System.err.println("SQL解析错误: " + e.getMessage());
        }
    }
}